package com.design.cjm.creational.singleton.example1;

import java.awt.*;

/**
 * @Author: Jie Ming Chen
 * @Date: 2018/9/19
 * @Version 1.0
 */
public class Singleton {

    /**
     * 直接实例化
     */
    private static Singleton ourInstance = new Singleton();

    public static Singleton getInstance() {
        return ourInstance;
    }

    private Singleton() {
    }

    public static void main(String[] args) {
        Singleton instance = Singleton.getInstance();
        Singleton instance1 = Singleton.getInstance();
        System.out.println(instance.toString());
        System.out.println(instance1.toString());
        System.out.println(instance == instance1);
        System.out.println(instance.equals(instance1));

    }
}